﻿@using OnlinePharmacyV001.ViewModel;
@using OnlinePharmacyV001.DA;
@model ProductViewModel
@{
    ViewBag.Title = "Index";
    Layout = "~/Views/Shared/_AdminLayout.cshtml";
}
<h2>
    Index</h2>
<p>
    @Html.ActionLink("Create New", "Create")
</p>
<table width="100%">
    <tr>
        <th>
            ID
        </th>
        <th>
            Cate Name
        </th>
        <th>
            Product Name
        </th>
        <th>
            Product Weight
        </th>
        <th>
            Product Price
        </th>
        <th>
            Status
        </th>
        <th>
            Edit
        </th>
        <th>
            Delete
        </th>
    </tr>
    @foreach (var item in Model.Products)
    {
        <tr>
            <td>
                @item.prodId
            </td>
            <td>
                <a href="/Category/Details/@(item.cateId)">@ProductService.GetCatById((int)item.cateId).CateName</a>
            </td>
            <td>
                <a href="/Products/Details/@(item.prodId)">
                    @Html.DisplayFor(modelItem => item.prodName)</a>
            </td>
            <td>
                @String.Format("{0:F}", item.prodWeight)
            </td>
            <td>
                @String.Format("{0:F}", item.prodPrice)
            </td>
            <td align="center">
                <a id="SetAct@(item.prodId)" href="javascript:SetAct(@(item.prodId), @((bool)item.prodStatus ? 0 : 1), 'Products')"
                            title="@((bool)item.prodStatus ? "Click để ko sử dụng" : "Click để sử dụng")">
                    <img alt="" src="@((bool)item.prodStatus ? "../../Content/AdminLayout/img/icons/yes.png" : "../../Content/AdminLayout/img/icons/no.png")" />
                </a>
            </td>
            <td>
                <a href="/Products/Edit/@(item.prodId)">
                    <img src="../../Content/AdminLayout/img/icons/icon-24-edit.png" /></a>
            </td>
            <td>
                <a href="/Products/Delete/@(item.prodId)">
                    <img src="../../Content/AdminLayout/img/icons/icon-24-delete.png" /></a>
            </td>
        </tr>
    }
</table>
